//@author A0096794H
#include "TimedTask.h"

TimedTask::TimedTask(string description, Date startTaskDate, Date endTaskDate) : Task(description)
{
	type = TIMED;
	startDate=startTaskDate;
	endDate=endTaskDate;
	startTime = NULL_TIME;
	endTime = NULL_TIME;
	taskParameterCounter=3;
}

TimedTask::TimedTask(string taskDescription, Date startTaskDate, Time startTaskTime,Time endTaskTime) : Task(taskDescription)
{
	type = TIMED;
	startDate = startTaskDate;
	endDate = startTaskDate;
	startTime = startTaskTime;
	endTime = endTaskTime;
	taskParameterCounter=4;
}

TimedTask::TimedTask(string taskDescription, Date startTaskDate, Time startTaskTime, Date endTaskDate, Time endTaskTime) : Task(taskDescription)
{
	type = TIMED;
	startDate = startTaskDate;
	startTime = startTaskTime;
	endDate = endTaskDate;
	endTime = endTaskTime;
	taskParameterCounter=5;
}

Date TimedTask::getStartDate()
{
	return startDate;
}

Date TimedTask::getEndDate()
{
	return endDate;
}

Time TimedTask::getStartTime()
{
	return startTime;
}

Time TimedTask::getEndTime()
{
	return endTime;
}

ResultType TimedTask::setStartDate(Date date)
{
	startDate = date;
	return SUCCESS;
}

ResultType TimedTask::setEndDate(Date date)
{
	endDate = date;
	return SUCCESS;
}

ResultType TimedTask::setStartTime(Time time)
{
	startTime = time;
	return SUCCESS;
}

ResultType TimedTask::setEndTime(Time time)
{
	endTime = time;
	return SUCCESS;
}
//@author A0099619J
string TimedTask::stringify()
{
	stringstream text;
	text <<TIMED << "," << description << ","
		 << startDate << ","
		 << startTime << ","
		 << endDate << ","
		 << endTime;
	saveDoneOrNotDone(text);
	return text.str();
}

string TimedTask::format()
{
	stringstream text;
	if(startTime==NULL_TIME)
	{
		text << description << ", "
		 << startDate.formatDate() << ", "
		 << endDate.formatDate();
	}
	else
	{
		text <<description << ", "
		 << startDate.formatDate() << ", "
		 << startTime.formatTime() << ", "
		 << endDate.formatDate() << ", "
		 << endTime.formatTime();
	}
	return text.str();
}